package top.aicats.blog.BlogManage.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.LinkedList;
import java.util.List;

/**
 * @author sjc
 * @version 1.0
 * @date 2020/1/9 20:13
 * @email 952491025@qq.com
 */
@Configuration
public class ConfigureAdapter extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 跨域拦截器5
        registry.addInterceptor(new CrossDomainInterceptor()).
                addPathPatterns("/**");

        List<String> includePath = new LinkedList<>();
//        includePath.add("/blogContent/addOneBlog");
//        includePath.add("/blogType/addMainType");
        //includePath.add("/blogType/deleteMainType");

        // 需要用户登录拦截器
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/admin/**").addPathPatterns(includePath);
    }

}
